from PyQt4 import QtCore, QtGui;

class EdgeArrowShape(QtGui.QGraphicsObject):
    def __init__(self, parent=None, qPos=None):
        super(EdgeArrowShape, self).__init__(parent);
        self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True);
        if qPos!=None:
            self.setPos(qPos);
        self.pathParent = parent;
        self.createArrowShape();
        
    def shape(self):
        qPath = QtGui.QPainterPath();
        qPath.addPolygon(self.qArrowShape);
        return qPath;
    
    def boundingRect(self):
        return self.qArrowShape.boundingRect();        
        
    def createArrowShape(self):
        p1 = QtCore.QPointF(-15,-8);
        p2 = QtCore.QPointF(4,0);
        p3 = QtCore.QPointF(-15,8);
        self.qArrowShape = QtGui.QPolygonF([p1, p2, p3]);
        
    def updateArrow(self, newP, edgePath):
        self.setRotation(-edgePath.angleAtPercent(1));
        self.setPos(newP);
        
    def paint(self, painter, option, widget):
        self.prepareGeometryChange();
        painter.setPen(QtGui.QPen(QtCore.Qt.red, 0.5));
        painter.setBrush(QtGui.QBrush(QtCore.Qt.yellow));
        painter.drawPolygon(self.qArrowShape);

    def setArrowShapeStyle(self, nStyle):
        pass;
    
    def setArrowShapeOption(self, nOpt, value):
        pass;
